const methods = {
  clearAddButtons() {
    const cells = this.cells;
    cells.forEach(cell => {
      cell.adding = false;
    });
    this.cells = [];
  },
  handleEditDuty(scope, day, time) {
    const name = scope.row.name;
    this.$emit('clickOneDuty', {
      name,
      day,
      time
    });
  },
  onClickCell(row, col) {
    this.clearAddButtons();
    const prop = col.property;
    const adding = Boolean(row[prop].adding);
    this.$set(row[prop], 'adding', !adding);
    this.cells.push(row[prop]);
  },
  onClickCreate(scope, day) {
    this.$emit('addDuty', {
      row: scope.row,
      day
    });
  }
};

export default methods;
